package com.xys.auth.service.impl;

import com.xys.auth.bean.Product;
import com.xys.auth.mapper.ProductMapper;
import com.xys.auth.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Service
public class ProductServiceImpl implements IProductService {

    @Autowired
    ProductMapper productMapper;

    @Override
    public List<Product> findAll() {
        List<Product> products = productMapper.findAll();
        return products;
    }

    @Override
    public int save(Product product) {
        product.setId(UUID.randomUUID().toString().replace("-",""));
        return productMapper.insert(product);
    }

    @Override
    public int delete(String id) {
        return productMapper.delete(id);
    }
}
